package com.keya.utils;


import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;

import java.io.File;
import java.util.List;

/**
 * 文件工具类
 * @author hexiaofei
 * @date 2023/11/21
 */
public class CustomFileUtils {


    /**
     * 遍历文件夹
     * @param path
     * @param fileList
     */
    public static void traverseFolder(String path, List<File> fileList) {
        File file = new File(path);
        if (file.exists()) {
            File[] files = file.listFiles();
            if (ObjectUtils.isNotEmpty(files)) {
                for (File file2 : files) {
                    if (file2.isDirectory()) {
                        traverseFolder(file2.getAbsolutePath(), fileList);
                    } else {
                        fileList.add(file2);
                    }
                }
            }
        }
    }

}

